
************************
***3 shocks together ***
************************
set more off
use temp1,clear
eststo clear
egen naf2yr = group(naf2 year)
global depvar "llaborpty"
global depvar_d1  "llaborpty_d1"
global RHS " gdp3intens shock3intens shock3intensi"
global RHS_d1 " gdp6intens shock6intens shock6intensi"
*
****************************
*FIRST TABLE: REDUCED FORM *
****************************
*NAIVE
*FE
eststo: xtreg  $depvar $RHS  i.naf2yr , robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  $RHS_d1   i.naf2yr , robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  $RHS_d1   i.naf2yr, robust cluster(firmid)  fe i(firmid)
*INV AND MATERIALS CONTROLED
*FE
eststo: xtreg  $depvar $RHS   linv lmatraw i.naf2yr, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1 $RHS_d1  linv_d1 lmatraw_d1 i.naf2yr, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  $RHS_d1  linv_d1 lmatraw_d1 i.naf2yr, robust cluster(firmid)  fe i(firmid)
*
log using $DIRLOG/Replication/tab-ReducedForm3shocks.txt, text replace
set linesize 255
esttab, keep(*intens* linv* lmatraw*) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, keep(*intens* linv* lmatraw*) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
log close



*********************************
***getting rid  of large firms***
*********************************
set more off
eststo clear
use temp1,clear
merge 1:1 firmid year using share_FRAtrade
drop if _merge == 2
tab _merge 
tab year if _merge == 1
sum shr_wgt, d 
scalar cut = .2
sum shr_wgt_max, d 
scalar cutm = .2
*
egen naf2yr = group(naf2 year)
global depvar "llaborpty"
global depvar_d1  "llaborpty_d1"
*
****************************
*FIRST TABLE: REDUCED FORM *
****************************
*INV AND MATERIALS CONTROLED
*P90
*FE
eststo: xtreg  $depvar shock3intens linv lmatraw i.naf2yr if shr_wgt<cut, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr if shr_wgt<cut, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr if shr_wgt<cut, robust cluster(firmid)  fe i(firmid)
*P90max
*FE
eststo: xtreg  $depvar shock3intens linv lmatraw i.naf2yr if shr_wgt_max<cutm, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr  if shr_wgt_max<cutm, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr  if shr_wgt_max<cutm, robust cluster(firmid)  fe i(firmid)
*
log using $DIRLOG/Replication/tab-ReducedForm_nobigfirm.txt, text replace
set linesize 255
***********************************************************************************
*ROBUSTNESS TABLE: REDUCED FORM: GETTING RID OF LARGE FIRMS  av market share>20%  *
***********************************************************************************
esttab, keep(shock* linv* lmatraw*) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, keep(shock* linv* lmatraw*) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
log close
*
scalar cut = .1
scalar cutm = .1
*P90
*FE
eststo: xtreg  $depvar shock3intens linv lmatraw i.naf2yr if shr_wgt<cut, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr if shr_wgt<cut, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr if shr_wgt<cut, robust cluster(firmid)  fe i(firmid)
*P90max
*FE
eststo: xtreg  $depvar shock3intens linv lmatraw i.naf2yr if shr_wgt_max<cutm, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr  if shr_wgt_max<cutm, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr  if shr_wgt_max<cutm, robust cluster(firmid)  fe i(firmid)
*P90max for top export intensity:
*FE
eststo: xtreg  $depvar shock3intens linv lmatraw i.naf2yr if shr_wgt_max<cutm & expintens_quant==4, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr  if shr_wgt_max<cutm & expintens_quant==4, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock6intens linv_d1 lmatraw_d1 i.naf2yr  if shr_wgt_max<cutm & expintens_quant==4, robust cluster(firmid)  fe i(firmid)
*
log using $DIRLOG/Replication/tab-ReducedForm_nobigfirm.txt, text append
set linesize 255
***********************************************************************************
*ROBUSTNESS TABLE: REDUCED FORM: GETTING RID OF LARGE FIRMS  av market share>10%  *
***********************************************************************************
esttab, keep(shock* linv* lmatraw*) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, keep(shock* linv* lmatraw*) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
log close




********************************
*** DEFLATED, robustness here***
********************************
use temp1,clear
global depvar "llaborpty_def"
global depvar_d1  "llaborpty_def_d1"
*
****************************
*FIRST TABLE: REDUCED FORM *
****************************
*NAIVE
*FE
eststo: xtreg  $depvar shock3intens  yd*, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock6intens  yd*, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock6intens  yd*, robust cluster(firmid)  fe i(firmid)
*INV AND MATERIALS CONTROLED
*FE
eststo: xtreg  $depvar shock3intens linv lmatraw yd*, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock6intens linv_d1 lmatraw_d1 yd*, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock6intens linv_d1 lmatraw_d1 yd*, robust cluster(firmid)  fe i(firmid)
*
log using $DIRLOG/Replication/tab-ReducedForm_nondef.txt, text append
set linesize 255
***********************************************************************
*FIRST TABLE: REDUCED FORM: NAIVE + innovation and materials  DEFLATED*
***********************************************************************
esttab, drop(yd*) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, drop(yd*) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
log close



********************
*FD instead of DH FD
********************
set more off
use temp1,clear
egen naf2yr = group(naf2 year)
global depvar "llaborpty"
global depvar_d1  "llaborpty_d1"
*
******************************
* TABLE: REDUCED FORM WITH FD*
******************************
*NAIVE
*FE
eststo: xtreg  $depvar shock3intens  i.naf2yr, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock7intens  i.naf2yr, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock7intens  i.naf2yr, robust cluster(firmid)  fe i(firmid)
*INV AND MATERIALS CONTROLED
*FE
eststo: xtreg  $depvar shock3intens  linv lmatraw i.naf2yr, robust cluster(firmid) fe i(firmid)
*FD
eststo: reg 	$depvar_d1  shock7intens  linv_d1 lmatraw_d1 i.naf2yr, robust cluster(firmid)
*FE+FD
eststo: xtreg   $depvar_d1  shock7intens  linv_d1 lmatraw_d1 i.naf2yr, robust cluster(firmid)  fe i(firmid)
*
log using $DIRLOG/Replication/tab-ReducedForm_nondef.txt, text append
set linesize 255
***********************************************************************************
* TABLE: REDUCED FORM: NAIVE + innovation and materials with FD instead of DH FD  *
***********************************************************************************
esttab, keep(shock* linv* lmatraw*) b(%4.3f) se(%4.3f) r2 starlevels({$^c$} 0.1 {$^b$} 0.05 {$^a$} 0.01)  tex  title() label
esttab, keep(shock* linv* lmatraw*) compress r2 starlevels(c 0.1 b 0.05 a 0.01)  b(%4.3f) se(%4.3f)
eststo clear
log close

